using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Travel
{
    public partial class Main : Form
    {   
        /// <summary>
        /// 
        /// </summary>
        private Travel.UserControls.MemberList ucMemberList = null;
        private Travel.UserControls.BookingList ucBookingList = null;      
        /// <summary>
        /// khai bao user manager
        /// </summary>
        private Travel.UserControls.UserManage ucManageUser = null;

        private int iHeight, iResUCHeight, iResLVHeight = 0;
        private int iWidth,iResUCWidth,iResLVWidth = 0;

        /// <summary>
        /// 
        /// </summary>
        public Main()
        {
            InitializeComponent();
        }

       

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Main_Load(object sender, EventArgs e)
        {
            //Base on Size(800,600)
            //this.Width = 800;
            //this.Height = 600;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void itm_Member_List_Click(object sender, EventArgs e)
        {
            ucMemberList = new Travel.UserControls.MemberList();
            if (panel2.Controls.Count > 0)
            {
                panel2.Controls.RemoveAt(0);
            }
            this.panel2.Controls.Add(ucMemberList);
            ucMemberList.Show();
           // if (WindowState == FormWindowState.Maximized)
           //{
           //    //Save Original UserControl Size
           //    iResUCHeight = this.ucMemberList.Height;
           //    iResUCWidth = this.ucMemberList.Width;
           //    iResLVHeight = this.ucMemberList.lvMmeber.Height;
           //    iResLVWidth = this.ucMemberList.lvMmeber.Width;
           //    //Process for UserControl Size
           //    iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucMemberList.Height;
           //    iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucMemberList.Width - panel1.Width; ;
           //    this.ucMemberList.Width += iWidth;
           //    this.ucMemberList.Height += iHeight;
           //    //Process for ListView Control Size
           //    iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucMemberList.lvMmeber.Height - 100;// -235;
           //    iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucMemberList.lvMmeber.Width - panel1.Width - 20;// -235;
           //    this.ucMemberList.lvMmeber.Width += iWidth;
           //    this.ucMemberList.lvMmeber.Height += iHeight;     
           //}
           // //Main_Resize(sender, e);
        }      

        #region "BOOKING REGION"

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void itm_Booking_Resort_Click(object sender, EventArgs e)
        {
            if (ucBookingList == null)
            {
                ucBookingList = new Travel.UserControls.BookingList();
            }

            if (panel2.Controls.Count > 0)
            {
                panel2.Controls.RemoveAt(0);
            }
           
                this.panel2.Controls.Add(ucBookingList);
           
            if (ucBookingList == null)
            {
                ucBookingList.Show();
            }

            if (WindowState == FormWindowState.Maximized)
            {
                //Save Original UserControl Size
                iResUCHeight = this.ucBookingList.Height;
                iResUCWidth = this.ucBookingList.Width;
                iResLVHeight = this.ucBookingList.lvBooking.Height;
                iResLVWidth = this.ucBookingList.lvBooking.Width;
                //Process for UserControl Size
                iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.Height;
                iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.Width - panel1.Width; ;
                this.ucBookingList.Width += iWidth;
                this.ucBookingList.Height += iHeight;
                //Process for ListView Control Size
                iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.lvBooking.Height - 100;// -235;
                iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.lvBooking.Width - panel1.Width - 20;// -235;
                this.ucBookingList.lvBooking.Width += iWidth;
                this.ucBookingList.lvBooking.Height += iHeight;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void itm_Booking_Addon_Click(object sender, EventArgs e)
        {
            if (ucBookingList == null)
            {             
                ucBookingList = new Travel.UserControls.BookingList();                
            }

            if (panel2.Controls.Count > 0)
            {
                panel2.Controls.RemoveAt(0);
            }

           this.panel2.Controls.Add(ucBookingList);

            

            if (ucBookingList == null)
            {
                ucBookingList.Show();
            }
            if (WindowState == FormWindowState.Maximized)
            {
                //Save Original UserControl Size
                iResUCHeight = this.ucBookingList.Height;
                iResUCWidth = this.ucBookingList.Width;
                iResLVHeight = this.ucBookingList.lvBooking.Height;
                iResLVWidth = this.ucBookingList.lvBooking.Width;
                //Process for UserControl Size
                iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.Height;
                iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.Width - panel1.Width; ;
                this.ucBookingList.Width += iWidth;
                this.ucBookingList.Height += iHeight;
                //Process for ListView Control Size
                iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.lvBooking.Height - 100;// -235;
                iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.lvBooking.Width - panel1.Width - 20;// -235;
                this.ucBookingList.lvBooking.Width += iWidth;
                this.ucBookingList.lvBooking.Height += iHeight;
            }
        }
      
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void itm_Booking_Service_Click(object sender, EventArgs e)
        {
            if (ucBookingList == null)
            {             
                ucBookingList = new Travel.UserControls.BookingList();                
            }

            if (panel2.Controls.Count > 0)
            {
                panel2.Controls.RemoveAt(0);
            }
                
            this.panel2.Controls.Add(ucBookingList);
            
            if (ucBookingList == null)
            {
                ucBookingList.Show();
            }
            if (WindowState == FormWindowState.Maximized)
            {
                //Save Original UserControl Size
                iResUCHeight = this.ucBookingList.Height;
                iResUCWidth = this.ucBookingList.Width;
                iResLVHeight = this.ucBookingList.lvBooking.Height;
                iResLVWidth = this.ucBookingList.lvBooking.Width;
                //Process for UserControl Size
                iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.Height;
                iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.Width - panel1.Width; ;
                this.ucBookingList.Width += iWidth;
                this.ucBookingList.Height += iHeight;
                //Process for ListView Control Size
                iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.lvBooking.Height - 100;// -235;
                iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.lvBooking.Width - panel1.Width - 20;// -235;
                this.ucBookingList.lvBooking.Width += iWidth;
                this.ucBookingList.lvBooking.Height += iHeight;
            }
        }

        #endregion          

        private void Main_Resize(object sender, EventArgs e)
        {
            #region "Maximium Size"
            if (WindowState == FormWindowState.Maximized)
            {
                if (this.ucMemberList != null)
                {
                    //Save Original UserControl Size
                    iResUCHeight = this.ucMemberList.Height;
                    iResUCWidth = this.ucMemberList.Width;
                    iResLVHeight = this.ucMemberList.lvMember.Height;
                    iResLVWidth = this.ucMemberList.lvMember.Width;
                    //Process for UserControl Size
                    iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucMemberList.Height;
                    iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucMemberList.Width - panel1.Width; ;
                    this.ucMemberList.Width += iWidth;
                    this.ucMemberList.Height += iHeight;
                    //Process for ListView Control Size
                    iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucMemberList.lvMember.Height - 100;// -235;
                    iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucMemberList.lvMember.Width - panel1.Width - 20;// -235;
                    this.ucMemberList.lvMember.Width += iWidth;
                    this.ucMemberList.lvMember.Height += iHeight;
                    this.ucMemberList.panel1.Location = new System.Drawing.Point(this.ucMemberList.panel1.Location.X + iWidth, 3);
                }

                if (this.ucBookingList != null)
                {
                    //Save Original UserControl Size
                    iResUCHeight = this.ucBookingList.Height;
                    iResUCWidth = this.ucBookingList.Width;
                    iResLVHeight = this.ucBookingList.lvBooking.Height;
                    iResLVWidth = this.ucBookingList.lvBooking.Width;
                    //Process for UserControl Size
                    iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.Height;
                    iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.Width - panel1.Width; ;
                    this.ucBookingList.Width += iWidth;
                    this.ucBookingList.Height += iHeight;
                    //Process for ListView Control Size
                    iHeight = Screen.PrimaryScreen.Bounds.Height - this.ucBookingList.lvBooking.Height - 100;// -235;
                    iWidth = Screen.PrimaryScreen.Bounds.Width - this.ucBookingList.lvBooking.Width - panel1.Width - 20;// -235;
                    this.ucBookingList.lvBooking.Width += iWidth;
                    this.ucBookingList.lvBooking.Height += iHeight;
                    this.ucBookingList.panel1.Location = new System.Drawing.Point(this.ucBookingList.panel1.Location.X + iWidth, 3);
                }
            }
            #endregion

            #region "Normal Size"
            if (WindowState == FormWindowState.Normal)
            {
                if (this.ucMemberList != null)
                {
                    ////Process for UserControl Size
                    this.ucMemberList.Width = iResUCWidth;
                    this.ucMemberList.Height = iResUCHeight;
                    //Process for ListView Control Size                    
                    this.ucMemberList.lvMember.Width = iResLVWidth;
                    this.ucMemberList.lvMember.Height = iResLVHeight;
                    this.ucMemberList.panel1.Location = new System.Drawing.Point(this.ucMemberList.panel1.Location.X - iWidth, 3);
                }

                if (this.ucBookingList != null)
                {
                    ////Process for UserControl Size
                    this.ucBookingList.Width = iResUCWidth;
                    this.ucBookingList.Height = iResUCHeight;
                    //Process for ListView Control Size                    
                    this.ucBookingList.lvBooking.Width = iResLVWidth;
                    this.ucBookingList.lvBooking.Height = iResLVHeight;
                    this.ucBookingList.panel1.Location = new System.Drawing.Point(this.ucBookingList.panel1.Location.X - iWidth, 3);
                }
            }
            #endregion

            #region "Minium Size"
            #endregion
        }

        public void getDefaultSize()
        {
            //Process Get Orginal UserControl MemberList            
            iResUCHeight = this.ucMemberList.Height;
            iResUCWidth = this.ucMemberList.Width;
            iResLVHeight = this.ucMemberList.lvMember.Height;
            iResLVWidth = this.ucMemberList.lvMember.Width;
        }

        private void taskItem3_Click(object sender, EventArgs e)
        {
            Member obj_Member = new Member();            
            //if (panel2.Controls.Count > 0)
            //{
            //    panel2.Controls.RemoveAt(0);
            //}
            //this.panel2.Controls.Add(obj_Member);
            obj_Member.Show();
        }

        private void taskItem6_Click(object sender, EventArgs e)
        {
            UserInfo obj_user = new UserInfo();
            obj_user.Show();
        }

        private void taskItem7_Click(object sender, EventArgs e)
        {
            ucManageUser = new Travel.UserControls.UserManage();
            if (panel2.Controls.Count > 0)
            {
                panel2.Controls.RemoveAt(0);
            }
            panel2.Controls.Add(ucManageUser);
            ucManageUser.Show();
        }

        private void taskItem10_Click(object sender, EventArgs e)
        {
            Booking obj_Booking = new Booking();
            //if (panel2.Controls.Count > 0)
            //{
            //    panel2.Controls.RemoveAt(0);
            //}
            //this.panel2.Controls.Add(obj_Member);
            obj_Booking.Show();
        }
    }
}